package jsyf.oa.dao.tmpevent;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

import jsyf.oa.entity.tmpEvent.EventAuditEntity;
import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;

@Repository
public class EventAuditDao extends BaseDao {

    public EventAuditDao() {
        super.iBaseEntity = new EventAuditEntity();
    }

    public List<EventAuditEntity> getEntityListByCondition(String condition, Object[] params) {
        List<JSONObject> jsonList = getJSONListByCondition(condition, params);
        List<EventAuditEntity> entityList = new ArrayList<>();
        for (int i = 0; i < jsonList.size(); i++) {
            EventAuditEntity entity = (EventAuditEntity) convertJson2Entity(jsonList.get(i));
            entityList.add(entity);
        }
        return entityList;
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, EventAuditEntity.class);
    }

    /*获取第一审核人*/
    public JSONObject getFirstParent( ) {

        StringBuffer sql = new StringBuffer();
        sql.append(" SELECT  \n");
        sql.append(" id AS id, \n");
        sql.append(" name AS name, \n");
        sql.append(" roleName AS roleName, \n");
        sql.append(" roleId AS roleId, \n");
        sql.append(" departId AS departId, \n");
        sql.append(" departName AS departName, \n");
        sql.append(" companyName AS companyName, \n");
        sql.append(" companyId AS companyId \n");
        sql.append(" FROM V_SYS_USER  \n");
        sql.append(" WHERE id=? \n");
        String[] params = {"201712161851433BAD8487BE30159C9E"};

        return super.queryForJsonObject(sql.toString(), params);
    }



}

